home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
-
- global proc int lockIntersections()
- //
- // Description :
- // Select two or more curve param point or edit points
- // and lock these points together to ensure an intersection.
- // NOTE: Works of the selection list.
- //
- {
- string $curveNames[] ;
- string $locators[] ;
- string $lsqNodes[] ;
- int $len ;
- int $i ;
-
- int $ok = 1 ;
- int $sc = 0 ;
-
- $curveNames = `ls -sl` ;
- $len = size($curveNames) ;
- if( $len == 0 ) return 0 ;
-
- // run filter to get only items of interest.
- //
- global int $gSelectEditPointsBit ;
- global int $gSelectCurveParmPointsBit ;
- string $curveNames[] = `filterExpand -ex true -sm $gSelectEditPointsBit -sm $gSelectCurveParmPointsBit $curveNames`;
-
- $len = size($curveNames) ;
- if( $len == 0 ) return 0 ;
- if( $ok ) {
-
- for( $i = 0 ; $i < $len ; $i++ ) {
- string $name = $curveNames[$i] ;
- string $tmpResults[] ;
- if( catch( $tmpResults = `pointCurveConstraint -ch 1 -rpo 1 $name` ) ) {
- $ok = 0 ;
- $sc = 1 ;
- } else {
- $locators[$i] = $tmpResults[0] ;
- $lsqNodes[$i] = $tmpResults[1] ;
- }
- }
- }
-
- //
- // Disconnect all locators but locator [0].
- // locator[0].wp[0] now fans out to all other nodes.
- // That way we have one locator controlling the position
- // of the intersection point.
- //
- string $inAttr ;
- if( $ok ) {
- $len = size($locators) ;
-
- string $newSrc = $locators[0] + ".wp[0]" ;
- for( $i = 1 ; $i < $len ; $i++ ) {
- string $dests[] ;
- string $locName = $locators[$i] ;
- $inAttr = $locName + ".wp[0]" ;
- $dests = `listConnections -p true $inAttr` ;
- if( size($dests) > 0 ) {
- disconnectAttr $inAttr $dests[0] ;
- connectAttr $newSrc $dests[0] ;
- }
- delete $locName ;
- }
- select -r $locators[0] ;
- }
- if( $ok != 1 ) $sc = $ok ;
- return $sc ;
- }
-